<?php
namespace app\common\business;

use app\common\model\mysql\OrderGoods as orderGoodsModel;
class OrderGoods extends BusiBase{
	public $model = null;
	public function __construct(){
		$this->model = new orderGoodsModel();
	}

	public function saveAll($data){
		try{
			$result = $this->model->saveAll($data);
			return $result->toArray();
		}catch(\Exception $e){
			return false;
		}
	}

	//根据订单id获取order_goods表中数据
	public function getByOrderId($orderId){
		$condition = [
			'order_id' => $orderId,
		];
		try{
			$orderGoods = $this->model->getByCondition($condition);
		}catch(\Exception $e){
			$orderGoods = [];
		}
		if(!$orderGoods){
			return [];
		}

		return $orderGoods->toArray();
	}
}